from django.db import models
from farmers.farmer.models import Farmer

class Produce_Type(models.Model):
    name = models.CharField(max_length=100)
    def __unicode__(self):
        return self.name

class Seasons(models.Model):
    name = models.CharField(max_length=100)
    start_date = models.DateField()
    end_date = models.DateField()
    def __unicode__(self):
        return self.name

class Crop_Type(models.Model):
    name = models.CharField(max_length=100)
    name_english = models.CharField(max_length=100)
    season = models.ForeignKey(Seasons)
    produce_type = models.ForeignKey(Produce_Type)
    def __unicode__(self):
        return self.name + " (" + self.name_english + ")"

class Crop(models.Model):
    farmer = models.ForeignKey(Farmer)
    quantity = models.IntegerField()
    date = models.DateField()
    updated_date = models.DateField()
    crop_type = models.ForeignKey(Crop_Type)
    def __unicode__(self):
        return self.farmer

class Market(models.Model):
    crop = models.ForeignKey(Crop_Type)
    price = models.DecimalField(decimal_places=2,max_digits=10) 
    year = models.IntegerField(max_length=2)
    def __unicode__(self):
        return self.crop.name + " " + str(self.year)


class Selling(models.Model):
    price = models.DecimalField(decimal_places=2,max_digits=10)
    crop = models.ForeignKey(Crop_Type)
    year = models.IntegerField()
    def __unicode__(self):
        return self.crop.name
